import { PillarOfFortuneModule } from "../module";

export class PillarOfFortuneEndState extends PillarOfFortuneModule.State {
    override onEnter(): void {
        const winner = this.context.players.find((p) => p.alive && p.isValid);
        this.context.players.sendMessage(
            `§a游戏结束,${winner ? "§e" + winner.name : "没有人"}胜利`
        );
        if (winner) {
            winner.title("§e恭喜你，获胜了");
        }
        this.runner.runDelay(() => {
            this.engine.stopGame();
        }, 10);
    }
}
